package com.itheima.demo;

import com.itheima.Service.UserService;
import com.itheima.Service.impl.UserServiceImpl;
import com.itheima.domain.User;
import org.junit.Test;

import java.util.List;

public class Demo {
    @Test
    public void findAll(){
        UserService userService = new UserServiceImpl();
        List<User> list = userService.findAll();
        for (User user : list) {
            System.out.println(user);
        }
    }
    @Test
    public void saveUser(){
        UserService userService = new UserServiceImpl();
        User user = new User();
        user.setUsername("杯子");
        user.setPwd("123");
        user.setAge(18);
        user.setSex("它");
        user.setHobby("装水");
        userService.saveUser(user);
    }
    @Test
    public void updateUser(){
        UserService userService = new UserServiceImpl();
        User user = new User();
        user.setUsername("杯子");
        user.setPwd("456");
        user.setId(29);
        userService.updateUser(user);
    }
    @Test
    public void deleteUser(){
        UserService userService = new UserServiceImpl();
        userService.deleteUser(33);
    }
    @Test
    public void saveUsers(){
        UserService userService = new UserServiceImpl();
        User user = new User();
        user.setUsername("杯子");
        user.setPwd("123");
        user.setAge(18);
        user.setSex("它");
        user.setHobby("装水");
        System.out.println("添加之前:"+user.getId());
        userService.saveUsers(user);//获取新增主键列的值赋给User对象的id属性
        System.out.println("添加之后:"+user.getId());
    }
}
